/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * filter.h
 * Copyright (C) chemek anouar 2012 <anouar.chemek@esprit.tn>
 *
 * WiScramb is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WiScramb is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _FILTER_H
#define _FILTER_H

#include "utils.h"
#include "sniffer.h"


#define MAX_AP_NUMBER 10
#define MAX_STA_NUMBER 1000

/*
 * Acces Point description
 */
struct access_point {
  u_int8_t bssid[IEEE80211_ADDR_LEN];
  int freq;
  int ssi;
  char ssid[IEEE80211_MAX_SSID_LEN];
};
typedef struct access_point access_point;

/*
 * station description
 */
struct station{
  u_int8_t adress[IEEE80211_ADDR_LEN];
  u_int8_t AP_adress[IEEE80211_ADDR_LEN];
};
typedef struct station station;


extern int sock_fd; //file descriptor (raw socket)
extern ssize_t buffer_len;

access_point *apvector; //tab of access_point
station *stationvector; //tab of station

int ap_number;
int sta_number;
int ssid_lenght;


void * ieee80211_frame_process(void *buffer);

//void ieee80211_frame_delimiter(char *buffer,struct ieee80211_mac_header *mac_h,struct ieee80211_radiotap_header *radio_h);

void ieee80211_frame_filter ( char *buffer,struct ieee80211_mac_header *mac_h,struct ieee80211_radiotap_header *radio_h );

void process_ieee80211_management(char *buffer,struct ieee80211_mac_header *mac_h,struct ieee80211_radiotap_header *radio_h);

void process_ieee80211_beacon(char *buffer,struct ieee80211_mac_header *mac_h,struct ieee80211_radiotap_header *radio_h,struct ieee80211_mgmt *mgmt);

void process_ieee80211_data(char *buffer,struct ieee80211_mac_header *mac_h);

void process_ieee80211_control(char *buffer,struct ieee80211_mac_header *mac_h,struct ieee80211_radiotap_header *radio_h);

void add_ap_to_apvector(struct ieee80211_mac_header *mac_h,struct ieee80211_radiotap_header *radio_h,struct ieee80211_mgmt *mgmt);

int add_sta_to_stationvector(struct ieee80211_mac_header *mac_h);


#endif
